<script setup lang="ts">
import useStore from './store'
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import { getSystemInfo, getMenuButtonBoundingClientRect, getNavigationBarHeight } from './utils/system'
onLaunch(() => {
  const { useSystemStore } = useStore()
  // 获取设备信息
  const system = getSystemInfo()
  console.log('System Info:', system)
  // 获取小程序胶囊信息
  const menuRect = getMenuButtonBoundingClientRect()
  console.log('Menu Button Rect:', menuRect)
  // 计算小程序顶部导航栏高度
  const navigationBarHeight = getNavigationBarHeight(menuRect.top, system.statusBarHeight, menuRect.height)
  console.log('Navbar Height:', navigationBarHeight)

  useSystemStore.setState({
    ...system,
    navBarHeight: navigationBarHeight,
    menuRect,
  })
})
onShow(() => {
  console.log('App Show')
})
onHide(() => {
  console.log('App Hide')
})
</script>
<style>
@tailwind base;
@tailwind components;
@tailwind utilities;
</style>
